<?php

class Items extends Controller {

    function view($id = null, $name = null) {
        $this->set('title', $name . ' - My Todo List');
        $this->Item->id = $id;
        $data = $this->Item->search();
        $this->set('todo', $data);
    }

    function view_all() {
        $this->set('title', 'All Items - My Todo List');
        $this->Item->set_page('1');
        $this->Item->set_limit('7');
        $this->Item->order_by('item_name', 'DESC');
        $data = $this->Item->search();
        $this->set('todo', $data);
    }

    function add() {
        $todo = $_POST['todo'];
        $this->set('title', 'Success - My Todo List');
        $this->Item->item_name = $todo;
        $this->Item->save();
    }

    function delete($id = null) {
        $this->set('title', 'Success - My Todo List');
        $this->Item->id = $id;
        $this->Item->delete();
    }

}
